<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
    <caption>个人信息页面</caption>
    <tr>
        <td>名字:</td><td id="name_td"></td>
    </tr>
    <tr>
        <td>照片:</td><td><img src="" alt="" style="width: 300px; height: 300px"></td>
    </tr>
    <tr>
        <td>年龄:</td><td id="age_td"></td>
    </tr>
    <tr>
        <td>工作:</td><td id="job_td"></td>
    </tr>
    <tr>
        <td>好友:</td>
        <td>
            <ul>
                <li>XXX</li>
                <li>XXX</li>
                <li>XXX</li>
            </ul>
        </td>
    </tr>
</table>
<input type="button" value="请求数据">

<!--引入一个jQuery框架-->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script>
    //给按钮添加点击事件
    $("input").click(function () {
        //准备一个对象  模拟是从服务器请求到的数据
        let person = {
            name:"刘德华",
            age:18,
            url:"../b.jpg",
            job:"歌手",
            friends:["张学友","古天乐","郭富城"]
        }
        //把数据展示到页面中
        $("#name_td").text(person.name);
        $("#age_td").text(person.age);
        $("#job_td").text(person.job);
        $("img").attr("src",person.url)

        //删除所有的li
        $("li").remove();
        for (let friend of person.friends) {
            let li = $("<li></li>");
            li.text(friend);
            //把li添加到ul里面
            $("ul").append(li)
        }

    });
</script>


</body>
</html>